package sxe.core.pair.list;

import snobject.snBoolean;
import snobject.snNil;
import snobject.snObject;
import snobject.snObjectArgList;
import snobject.snPair;
import step.EvaluationFailure;
import step.FunctionWrapper;

public class contains extends FunctionWrapper {

	@Override
	public snObject Call(snObjectArgList argv) throws EvaluationFailure,
			ClassCastException, ArrayIndexOutOfBoundsException {
				
		snPair p = argv.popPair();
		snObject target = argv.popObject();
			
		while(!snNil.NIL.equals(p.getRight()))
		{
			if(p.getLeft().equals(target))
				return snBoolean.TRUE;
			p = (snPair)p.getRight();
		}
		if(p.getLeft().equals(target))
			return snBoolean.TRUE;
							
		return(snBoolean.FALSE);
	}

}
